﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Channels;
using System.ServiceModel;
using System.Drawing.Imaging;

namespace PresentItNow
{
    class Utils
    {
        public static Binding CreateBinding()
        {
            NetTcpBinding binding = new NetTcpBinding();
            binding.MaxReceivedMessageSize = 1000000000;
            binding.MaxBufferSize = 1000000000;
            binding.ReaderQuotas.MaxArrayLength = 1000000000;
            binding.Security.Mode = SecurityMode.None;

            return binding;
        }

        public static ImageCodecInfo GetEncoder(ImageFormat format)
        {

            ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();

            foreach (ImageCodecInfo codec in codecs)
            {
                if (codec.FormatID == format.Guid)
                {
                    return codec;
                }
            }
            return null;
        }
    }
}
